export function setCookie(key, value, seconds, path = '/') {
    const date = new Date()
    // 设置生效时间
    date.setTime(date.getTime() - 8 * 3600 * 1000 + seconds * 1000)
    document.cookie = `${key}=${value};expires=${date};path=${path}`
}

// 获取cookie
export function getCookie(key) {
    const cookies = document.cookie
    if(cookies === '') return 
    const cookiesArr = cookies.split('; ')
    for(let a = 0; a < cookiesArr.length; a++) {
        let brr = cookiesArr[a].split('=')
        if(brr[0] === key) {
            return brr[1]
        }
    }
}

// 删除cookie
export function removeCookie(key, path = '/') {
    setCookie(key, null, -1, path)
}